package com.ssl.ware.utils;

import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GlobalCoordinates;

public class DistanceCalculateUtils { //按距离计算运费时使用
    public static Integer calculateDistance(String tarLat, String tarLong, String srcLat, String srcLong) {
        GlobalCoordinates tar = new GlobalCoordinates(Double.parseDouble(tarLat), Double.parseDouble(tarLong));
        GlobalCoordinates src = new GlobalCoordinates(Double.parseDouble(srcLat), Double.parseDouble(srcLong));

        Double kMeter = new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.WGS84, tar, src).getEllipsoidalDistance() / 1000;
        return kMeter.intValue();
    }
}
